﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DayPilot.Web.Mvc;
using DayPilot.Web.Mvc.Enums;
using DayPilot.Web.Mvc.Events.Calendar;

namespace TCM.Controllers
{
    public class CalendarController : Controller
    {
        //private TCMContext db = new TCMContext();

        //
        // GET: /Calendar/

        public ActionResult Index()
        { 
            
            return View();
        }

        public ActionResult Backend()
        {

            return new Dpc().CallBack(this);
         //   return new Dpc().CallBack(this);
        }

        class Dpc : DayPilotCalendar
        {


           // TCMContext db = new TCMContext();


            protected override void OnInit(InitArgs e)
            {
                Update(CallBackUpdateType.Full);
            }

            protected override void OnFinish()
            {
                if (UpdateType == CallBackUpdateType.None)
                {
                    return;
                }
                var events = new List<CalendarBase>
                 {
                 new CalendarBase { CourseId = 1,   CourseName = "English", StartOfDayDateTime = DateTime.Parse("3/17/2013 10:30:00 AM"),EndOfDayDateTime= DateTime.Parse("3/17/2013 12:00:00 PM") },
                 new CalendarBase { CourseId = 2,   CourseName = "french", StartOfDayDateTime = DateTime.Parse("3/17/2013 12:30:00 PM"),EndOfDayDateTime= DateTime.Parse("3/17/2013 2:00:00 PM") },
                 new CalendarBase { CourseId = 3,   CourseName = "English", StartOfDayDateTime = DateTime.Parse("3/19/2013 1:30:00 AM"),EndOfDayDateTime= DateTime.Parse("3/19/2013 2:00:00 AM") },
                 new CalendarBase { CourseId = 4,   CourseName = "English", StartOfDayDateTime = DateTime.Parse("3/19/2013 5:00:00 AM"),EndOfDayDateTime= DateTime.Parse("3/19/2013 7:00:00 AM") },
            };


                Events = from ev in events select ev;

                DataIdField = "CourseId";
                DataTextField = "CourseName";
                DataStartField = "StartOfDayDateTime";
                DataEndField = "EndOfDayDateTime";
            }
           
        }
       
    }

}
